Repository navigation
Resolve empty SQLServer aggregate column labels during result merge (#23799) - #40584
Merged
Merged
Conversation
kimmking
approved these changes
Dec 4, 2026
terrymanu
approved these changes
Dec 4, 2026
terrymanu
left a comment
Member
There was a problem hiding this comment.
Summary
The local candidate adds regression tests for SELECT *, AVG-derived columns, and multiple aggregates, verifying assigned column indexes and complete merged results. The increases in three existing complexity warnings are retained under explicit user authorization for this task only.
Result
Review Result: Mergeable
No blocking issues or required changes remain.
Evidence
- All 36 tests passed; all three new tests detect the original defect.
- Spotless and Checkstyle both exited 0 and covered both changed files.
- The quality scanner exited 1 solely for an existing, unchanged, unrelated helper diagnostic; no new diagnostics were introduced.
- Two independent complete reviews and final review-session validation passed.
Coverage
Public head b3b21a0 plus uncommitted local changes in two files. The complete PR and local delta were reviewed.
This is a code-scope conclusion; CI was not reviewed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #23799.
Background
SQLServer JDBC returns an empty column label for aggregate columns without aliases, so sharded
select count(1) from t_orderfailed during result merge with:java.lang.IllegalStateException: Can't find index: AggregationProjection(...), please add alias for aggregate selections.Change
Following the maintainer-accepted direction,
ShardingDQLResultMergernow builds the column-label index map with a SQLServer-scoped fallback for empty labels: column label -> JDBC column name -> the positionally aligned expanded projection's column label, so the key matches the label thatsetIndexForAggregationProjectionderives from the sameAggregationProjection. Non-SQLServer protocols and non-empty labels keep the previous behavior unchanged.features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/merge/dql/ShardingDQLResultMerger.javafeatures/sharding/core/src/test/java/org/apache/shardingsphere/sharding/merge/dql/ShardingDQLResultMergerTest.javaVerification
assertBuildGroupByMemoryMergedResultWithSQLServerEmptyColumnLabelsimulates SQLServer metadata with an empty label/name; the focused test class passes 33/33.spotless:check checkstyle:check -Pcheckpasses with 0 Checkstyle violations.AI assistance
Implemented with AI assistance; the change scope and affected files are listed above.